/* 
 * @Author: 21克的爱情
 * @Date: 2020-09-03 13:08:30
 * @Email: raohong07@163.com
 * @LastEditors: 21克的爱情
 * @LastEditTime: 2020-10-03 22:27:55
 * @Description: 
 */
import 'package:flustars/flustars.dart';
import 'package:ki5k_video/models/origin.dart';
import 'package:ki5k_video/resources/AppOriginConfig.dart';

import '../service/service_method.dart';

class Api {
//   // 高德地图主域名地址
//   static final String AMAP_HOST = "https://restapi.amap.com";

//   // 切换请求的域名地址
  static String host = "https://movie.ki5k.com/api.php";

  Api(){
    // host = SpUtil.getString("originUrl");
    // print('22222---${host}---2222');

    // print('获取缓存${SpUtil.isInitialized()}');
    // print('获取缓存${SpUtil.getString("originUrl")}');
  }

  // 获取某个城市兄弟的信息
  static Future getSearchData(data) async {
    return await HTTP().ajax("http://cj.okzy.tv/inc/apickm3u8s.php", method: 'get', data: data, dataType: 'xml');
  }
  // 获取某个城市兄弟的信息
  static Future getSearchDetail(data) async {
    return await HTTP().ajax("http://cj.okzy.tv/inc/apickm3u8s.php", method: 'get', data: data, dataType: 'xml');
  }

  // 获取某个城市兄弟的信息
  Future getHomeVideo(data, {int index=0}) async {
    return await HTTP().ajax(AppOriginConfig().currentUrl(index), method: 'get', data: data, dataType: 'xml');
  }

  // api视频解析 http://api.ikancloud.cn/api.php?url=http%3A%2F%2Fv.qq.com%2Fx%2Fcover%2Fmzc002003qfojfs%2Fo0034ec5q14.html&danmu=0
  Future getApiVideo(data) async {
    return await HTTP().ajax("http://dy.ataoju.com/svip/api.php", method: 'get', data: data, dataType: 'xml');
  }

  // api视频解析 http://api.ikancloud.cn/api.php?url=http%3A%2F%2Fv.qq.com%2Fx%2Fcover%2Fmzc002003qfojfs%2Fo0034ec5q14.html&danmu=0
  Future getApi2Video(data) async {
    return await HTTP().ajax("https://by.98a.ink/api.php", method: 'get', data: data, dataType: 'jsonp');
  }

  // 获取某个城市兄弟的信息x
  static Future getPageData(data) async {
    return await HTTP().ajax("https://m.pianku.tv/$data", method: 'get', data: null, dataType: 'xml');
  }

  // 搜索视频 https://www.pianku.tv/s/go.php?q=lou
  static Future getSearchVideoData(String searchStr) async {
    return await HTTP().ajax("https://m.pianku.tv/s/go.php?q=$searchStr", method: 'get', data: {}, dataType: 'xml');
  }

  // 获取app版本
  static Future getAppVersionMd() async {
    return await HTTP().ajax('https://raw.githubusercontent.com/CodeGather/ki5k_video/master/READChangeLog.md', method: 'get', dataType: 'xml');
  }
  // 获取app版本
  static Future getAppVersion() async {
    return await HTTP().ajax('https://gitee.com/study2015/ki5k_video/raw/master/update.json', method: 'get');
    // return await HTTP().ajax('https://raw.githubusercontent.com/CodeGather/ki5k_video/master/READChangeLog.md', method: 'get', dataType: 'xml');
    // return await HTTP().ajax('https://ki5k.com/wp-content/uploads/2020/09/update.json', method: 'get', dataType: 'xml');
  }
  // 下载App
  // static Future downloadFile( downloadUrl, savePath, cancelToken, Function downloadProgress, Function success, Function error ) async {
  //   return await HTTP().downloadFile(downloadUrl, savePath, cancelToken, downloadProgress: downloadProgress, success: success, error: error);
  // }
  
}